package com.invengo.library_rfid.analyze.utils.uhf.TIAOMHZH;


import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class ZHENGZBDS {
    /// <summary>  
    /// 非负数字。  
    /// </summary>
    public static String ZZValidNonNegativeNumeric = "^\\d+[.]?\\d*$";

    /// <summary>  
    /// 数字。  
    /// </summary>
    public static String ZZValidNumeric = "^[-]?\\d+[.]?\\d*$";

    /// <summary>  
    /// 非负整数  
    /// </summary>
    public static String ZZValidNonNegativeInt = "^\\d+$";


    /// <summary>
    /// 整数
    /// </summary>
    public static String ZZValidInt = "^-?\\d+$";

    /// <summary>  
    /// 负整数。  
    /// </summary>
    public static String ZZValidNegativeInt = "^-[0-9]*[1-9][0-9]*$";

    /// <summary>  
    /// 正整数。  
    /// </summary>
    public static String ZZValidPositiveInt = "^[0-9]*[1-9][0-9]*$";

    /// <summary>  
    /// 非正整数。  
    /// </summary>
    public static String ZZValidNonPositiveInt = "^((-\\d+)|(0+))$";

    /// <summary>
    /// 0~9的数字
    /// </summary>        
    public static String ZZValidNumber = "^[0-9]*$";

    /// <summary>
    /// IP地址
    /// </summary>
    public static String ZZValidIPAddress = "^(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5]).(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5]).(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5]).(\\d{1,2}|1\\d\\d|2[0-4]\\d|25[0-5])$";

    /// <summary>
    /// MAC地址
    /// </summary>
    public static String ZZValidMACAddress = "[0-9A-F][0-9A-F]-[0-9A-F][0-9A-F]-[0-9A-F][0-9A-F]-[0-9A-F][0-9A-F]-[0-9A-F][0-9A-F]-[0-9A-F][0-9A-F]";

    /// <summary>
    /// 十六进制数
    /// </summary>
    public static String ZZValidHexdecima = "^[0-9a-fA-F]+$";

    /// <summary>
    /// 手机号码
    /// </summary>
    public static String ZZValidCellPhone = "^(13|14|15|16|17|18|19)\\d{9}$";

    /// <summary>
    /// 匹配移动手机号
    /// </summary>
    public static String PATTERN_CMCMOBILENUM = "^1(3[4-9]|5[012789]|8[78])\\d{8}$";

    /// <summary>
    /// 匹配电信手机号
    /// </summary>
    public static String PATTERN_CTCMOBILENUM = "^18[09]\\d{8}$";

    /// <summary>
    /// 匹配联通手机号
    /// </summary>
    public static String PATTERN_CUTMOBILENUM = "^1(3[0-2]|5[56]|8[56])\\d{8}$";

    /// <summary>
    /// 匹配CDMA手机号
    /// </summary>
    public static String PATTERN_CDMAMOBILENUM = "^1[35]3\\d{8}$";

    /// <summary>
    /// 电子邮件
    /// </summary>
    public static String ZZValidEMail = "^([\\w-\\.]+)@((\\[[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.)|(([\\w-]+\\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\\]?)$";
    //public static String ZZValidEMail = "\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*";

    /// <summary>
    /// 身份证号码
    /// </summary>
    public static String ZZValidIdentityCard = "^(\\d{15}$|^\\d{18}$|^\\d{17}(\\d|X|x))$";

    /// <summary>
    /// 电话号码
    /// 电话号码格式："XXX-XXXXXXX"、"XXXX-XXXXXXXX"、"XXX-XXXXXXX"、"XXX-XXXXXXXX"、"XXXXXXX"和"XXXXXXXX"。
    /// </summary>
    public static String ZZValidTelephone = "^(\\d{3,4}-)?\\d{7,8}$";

    /// <summary>
    /// 时间正则表达式:XX:XX :[0-5]?\\d
    /// </summary>
    public static String ZZValidHMTime = "^((20|21|22|23|[0-1]?\\d):[0-5]?\\d)$";

    /// <summary>
    /// 时间正则表达式:XX:XX:XX 
    /// </summary>
    public static String ZZValidHMSTime = "^((20|21|22|23|[0-1]?\\d):[0-5]?\\d:[0-5]?\\d)$";

    /// <summary>
    /// 正则表达式。  
    /// </summary>
    /// <param   name="str">预检查的字符串。</param>   
    /// <param   name="ZZValidItem">正则表达式字符串。</param>   
    /// <returns>true:符合格式;false:不符合格式。</returns>   
    public static boolean IsValidString(String str, String ZZValidItem) {
        Pattern pattern = Pattern.compile(ZZValidItem);
        Matcher matcher = pattern.matcher(str);
        return matcher.find();
    }

    /// <summary>
    /// 手机号码是否正确
    /// </summary>
    /// <param name="str"></param>
    /// <returns></returns>
    public static boolean IsValid_Mobile(String str) {
        return IsValidString(str, ZZValidCellPhone);
    }

    /// <summary>
    /// 电子邮箱是否正确
    /// </summary>
    /// <param name="str"></param>
    /// <returns></returns>
    public static boolean IsValid_EMail(String str) {
        return IsValidString(str, ZZValidEMail);
    }


    /// <summary>
    /// IP地址是否正确
    /// </summary>
    /// <param name="str"></param>
    /// <returns></returns>
    public static boolean IsValid_IPAddress(String str) {
        return IsValidString(str, ZZValidIPAddress);
    }

    /// <summary>
    /// 电话号码是否正确
    /// </summary>
    /// <param name="str"></param>
    /// <returns></returns>
    public static boolean IsValid_szTelephone(String str) {
        return IsValidString(str, ZZValidTelephone);
    }

    /// <summary>
    /// 时间
    /// </summary>
    /// <param name="str"></param>
    /// <returns></returns>
    public static boolean IsValid_szTime(String str) {
        String[] list = str.split(":");
        if (list.length == 3) {
            return IsValidString(str, ZZValidHMSTime);
        } else {
            return IsValidString(str, ZZValidHMTime);
        }
    }

    /// <summary>
    /// 身份证校验
    /// </summary>
    /// <param name="str"></param>
    /// <returns></returns>
    public static boolean IsValid_IdentityCard(String str) {
        return IsValidString(str, ZZValidIdentityCard);
    }
}
